import myAxios from '@/utils/request'
import type { attrInfoType, AttrListType } from './model/AttrModel'
import type { categoryIdType } from './model/CategoryStateModel'

//使用枚举定义接口
enum Api {
    //获取属性列表数据
    getAttrInfoList = '/admin/product/attrInfoList/',

    //删除一个属性列表数据
    deleteOneAttr = '/admin/product/deleteAttr/',

    //添加属性或更新属性
    savaOrUpdateAttr = '/admin/product/saveAttrInfo'
}

//获取属性列表数据
export const reqGetAttrListDataByCategory3Id = ({ category1Id, category2Id, category3Id }: categoryIdType) => {
    return myAxios.get<any, AttrListType
    >(`${Api.getAttrInfoList}${category1Id}/${category2Id}/${category3Id}`)
}

//删除一个属性列表数据
export const reqDeleteOneAttr = (AttrId: number) => {
    return myAxios.delete(`${Api.deleteOneAttr}/${AttrId}`)
}

//添加属性或更新属性
export const reqSaveOrUpdateAttr = (attrInfo: attrInfoType) => {
    return myAxios.post<any, null>(`${Api.savaOrUpdateAttr}`, attrInfo)
}